package jjn.carl.linkedlist;

import commons.ListNode;

/**
 * @author Jiang Jining
 * @since 2023-07-02 22:11
 */
public class LeetCode206_Recursion {
    public ListNode reverseList(ListNode head) {
        return reverse(head, null);
    }
    
    private ListNode reverse(ListNode current, ListNode pre) {
        if (current == null) {
            return pre;
        }
        ListNode temp = current.next;
        current.next = pre;
        return reverse(temp, current);
    }
}
